ConfigEntry

An entry for a config setting list. Presents the setting name, any prefix text, as well as content buttons and decorations.

Author

fzzyhmstrs

Since

0.6.0

Parameters

parentElement

DynamicListWidget the settings widget the entry is being added to. This is provided internally; Fzzy Config asks for instances of Function$lt;DynamicListWidget, ConfigEntry> so it can finish construction lazily when needed.

content

ContentBuilder.BuildResult built contents of this entry.

texts

Translatable.Result translation information for this entry. This is provided by EntryCreator.CreatorContext

See also

Samples

import me.fzzyhmstrs.fzzy_config.config.ConfigGroup
import me.fzzyhmstrs.fzzy_config.entry.EntryCreator
import me.fzzyhmstrs.fzzy_config.screen.decoration.Decorated
import me.fzzyhmstrs.fzzy_config.screen.widget.DynamicListWidget
import me.fzzyhmstrs.fzzy_config.screen.widget.LayoutWidget
import me.fzzyhmstrs.fzzy_config.screen.widget.TextureDeco
import me.fzzyhmstrs.fzzy_config.screen.widget.TooltipChild
import me.fzzyhmstrs.fzzy_config.screen.widget.custom.CustomButtonWidget
import me.fzzyhmstrs.fzzy_config.util.FcText
import me.fzzyhmstrs.fzzy_config.util.FcText.translate
import me.fzzyhmstrs.fzzy_config.util.Ref
import net.minecraft.client.gui.widget.ClickableWidget
import net.minecraft.text.Text
import java.util.function.BiFunction
import java.util.function.Consumer

fun main() { 
   //sampleStart 
   val function: BiFunction<DynamicListWidget, Int, out DynamicListWidget.Entry> = BiFunction { listWidget, _ ->
    val contentBuilder = ConfigEntry.ContentBuilder(context, context.actions.map { ConfigEntry.ActionDecorationWidget.config(it) })
    contentBuilder.decoration(TextureDeco.DECO_OPEN_SCREEN, 2, 2)
    contentBuilder.layoutContent { contentLayout ->
        contentLayout.add(
            "open_screen",
            CustomButtonWidget.builder(context.texts.name) { context.misc.get(OPEN_SCREEN)?.accept(context.scope) }
                .narrationSupplier { _ -> context.texts.name.copyContentOnly() }
                .width(110)
                .build(),
            LayoutWidget.Position.ALIGN_JUSTIFY,
            LayoutWidget.Position.BELOW)
    }

    ConfigEntry(listWidget, contentBuilder.build(), context.texts)
}
return listOf(EntryCreator.Creator(context.scope, context.texts, function)) 
   //sampleEnd
}

Constructors

Link copied to clipboard

Types

Link copied to clipboard

A decoration widget that renders an action icon from an Action and displays its tooltip

Link copied to clipboard
class ContentBuilder(context: EntryCreator.CreatorContext, actionWidgets: List<AbstractDecorationWidget>)

Builds content information for constructing a ConfigEntry

Properties

Link copied to clipboard
open override var lastSelected: Element?

getter and setter for the cached element.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override val skip: Boolean

Whether the search should exclude this content from search results. This is active state, so can change between true and false as needed.

Link copied to clipboard
open override val texts: Translatable.Result

The searchable texts. Both desc and prefix of the result are searched as "description"

Functions

Link copied to clipboard
open fun appendTitleNarrations(builder: NarrationMessageBuilder)
Link copied to clipboard
fun atY(mouseY: Int): Boolean
Link copied to clipboard
open fun charTyped(chr: Char, modifiers: Int): Boolean
Link copied to clipboard
open override fun getFocused(): Element?
Link copied to clipboard
open override fun getFocusedPath(): GuiNavigationPath?
Link copied to clipboard
open override fun getNavigationFocus(): ScreenRect
Link copied to clipboard
Link copied to clipboard
open override fun getNavigationPath(navigation: GuiNavigation): GuiNavigationPath?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun handleContext(contextType: ContextType, position: Position): Boolean

Handle a context event. This will be triggered by a parent, typically on key press or mouse click. A parent object can of course also be a context handler, handle context as applicable and then pass the event downstream for further handling.

Link copied to clipboard
open fun hoveredElement(mouseX: Double, mouseY: Double): Optional<Element>
Link copied to clipboard
open override fun init()
Link copied to clipboard
open override fun isDragging(): Boolean
Link copied to clipboard
open override fun isFocused(): Boolean
Link copied to clipboard
open override fun isMouseOver(mouseX: Double, mouseY: Double): Boolean
Link copied to clipboard
open fun keyPressed(keyCode: Int, scanCode: Int, modifiers: Int): Boolean
Link copied to clipboard
open fun keyReleased(keyCode: Int, scanCode: Int, modifiers: Int): Boolean
Link copied to clipboard
open override fun mouseClicked(mouseX: Double, mouseY: Double, button: Int): Boolean
Link copied to clipboard
open fun mouseDragged(mouseX: Double, mouseY: Double, button: Int, deltaX: Double, deltaY: Double): Boolean
Link copied to clipboard
open fun mouseMoved(mouseX: Double, mouseY: Double)
Link copied to clipboard
open fun mouseReleased(mouseX: Double, mouseY: Double, button: Int): Boolean
Link copied to clipboard
open fun mouseScrolled(mouseX: Double, mouseY: Double, horizontalAmount: Double, verticalAmount: Double): Boolean
Link copied to clipboard
fun onAdd(parentPos: Pos, previous: DynamicListWidget.Entry?)
Link copied to clipboard
open override fun onResize()
Link copied to clipboard
open override fun onScroll(dY: Int)
Link copied to clipboard
open override fun popLast()

Indicates that the overlay has been removed and the parent should return focus to the cached element, if any, in lastSelected

Link copied to clipboard
open override fun provideContext(builder: ContextResultBuilder)

Add a set of grouped context action builders to a result

Link copied to clipboard
open override fun pushLast()

Indicates to the parent element to cache it's current focused element. The current focused element should be stored in lastSelected

Link copied to clipboard
open override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float)

Renders this entry. Works exactly as one would expect for any other render call.

Link copied to clipboard
open override fun renderBorder(context: DrawContext, x: Int, y: Int, width: Int, height: Int, mouseX: Int, mouseY: Int, hovered: Boolean, focused: Boolean, delta: Float)
Link copied to clipboard
open override fun renderEntry(context: DrawContext, x: Int, y: Int, width: Int, height: Int, mouseX: Int, mouseY: Int, hovered: Boolean, focused: Boolean, delta: Float)
Link copied to clipboard
open override fun renderExtras(context: DrawContext, x: Int, y: Int, width: Int, height: Int, mouseX: Int, mouseY: Int, hovered: Boolean, focused: Boolean, delta: Float)
fun renderExtras(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float)
Link copied to clipboard
open override fun renderHighlight(context: DrawContext, x: Int, y: Int, width: Int, height: Int, mouseX: Int, mouseY: Int, hovered: Boolean, focused: Boolean, delta: Float)
Link copied to clipboard
open fun resetHover(mouseX: Double, mouseY: Double)

When called the parent element should reselect a hovered element based on the supplied mouse positions, if it tracks such things

Link copied to clipboard
fun scroll(dY: Int)
Link copied to clipboard
open override fun setDragging(dragging: Boolean)
Link copied to clipboard
open override fun setFocused(focused: Boolean)
open override fun setFocused(focused: Element?)
Link copied to clipboard
open override fun toString(): String